public class Rotate {
    // leetcoe 旋转图像
    // https://leetcode.cn/problems/rotate-image/description/?envType=study-plan-v2&envId=top-100-liked
    public void rotate(int[][] matrix) {
        int n = matrix.length;
        int xl = 0, xr = n - 1, yt = 0, yb = n - 1;
        for (int i = 0; i < n/2; i++) {
            int index = 0;
            while (xl + index < xr) {
                int tmp = matrix[yt][xl+index];
                matrix[yt][xl+index] = matrix[yb-index][xl];
                matrix[yb-index][xl] = matrix[yb][xr-index];
                matrix[yb][xr-index] = matrix[yt+index][xr];
                matrix[yt+index][xr] = tmp;
                index++;
            }
            xl++;
            xr--;
            yt++;
            yb--;
        }
    }

    public static void main(String[] args) {
        Rotate rotate = new Rotate();
        int[][] matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        rotate.rotate(matrix);
        System.out.println(666);
    }
}
